package com.hongning.railway.data.http;



import com.hongning.railway.data.HttpDataSource;
import com.hongning.railway.data.http.service.ApiService;
import com.hongning.railway.entity.LoginEntity;
import com.hongning.railway.entity.reqbean.MettingMessageBean;
import com.hongning.railway.entity.reqbean.QueryCpInfoRequestBean;
import com.hongning.railway.entity.reqbean.QuestionRequestListBean;
import com.hongning.railway.entity.reqbean.QuestionResultBean;
import com.hongning.railway.entity.reqbean.QuestionResultListBean;
import com.hongning.railway.entity.reqbean.ReqAddExamScore;
import com.hongning.railway.entity.reqbean.ReqAddExperience;
import com.hongning.railway.entity.reqbean.ReqAddPages;
import com.hongning.railway.entity.reqbean.ReqAddScoreBean;
import com.hongning.railway.entity.reqbean.ReqAddViewOrPraise;
import com.hongning.railway.entity.reqbean.ReqAnswerCheck;
import com.hongning.railway.entity.reqbean.ReqAnswerSubmit;
import com.hongning.railway.entity.reqbean.ReqAssessesIntegral;
import com.hongning.railway.entity.reqbean.ReqAssessesIntegralBean;
import com.hongning.railway.entity.reqbean.ReqCadreListBean;
import com.hongning.railway.entity.reqbean.ReqCategory;
import com.hongning.railway.entity.reqbean.ReqDynamicBean;
import com.hongning.railway.entity.reqbean.ReqExam;
import com.hongning.railway.entity.reqbean.ReqExperienceList;
import com.hongning.railway.entity.reqbean.ReqKaoHeBaseBean;
import com.hongning.railway.entity.reqbean.ReqKaoHeGroupBean;
import com.hongning.railway.entity.reqbean.ReqKaoHeListBean;
import com.hongning.railway.entity.reqbean.ReqMemberList;
import com.hongning.railway.entity.reqbean.ReqNewDetail;
import com.hongning.railway.entity.reqbean.ReqNewsBean;
import com.hongning.railway.entity.reqbean.ReqScoreBean;
import com.hongning.railway.entity.reqbean.ReqUpdateExperience;
import com.hongning.railway.entity.reqbean.ReqVideoBean;
import com.hongning.railway.entity.reqbean.RosterMainBean;
import com.hongning.railway.entity.reqbean.ThreesessionSanDoneLessonBean;
import com.hongning.railway.entity.reqbean.UpdatesignBean;
import com.hongning.railway.entity.resbean.BaseRes;
import com.hongning.railway.entity.resbean.BaseResCadreListBean;
import com.hongning.railway.entity.resbean.BaseResExam;
import com.hongning.railway.entity.resbean.DataBeanX;
import com.hongning.railway.entity.resbean.Fileterbean;
import com.hongning.railway.entity.resbean.NewsCategoryBean;

import com.hongning.railway.entity.resbean.ResAnswerCheck;
import com.hongning.railway.entity.resbean.ResAnswerSubmitBean;
import com.hongning.railway.entity.resbean.ResCadreBean;
import com.hongning.railway.entity.resbean.ResDetailScore;
import com.hongning.railway.entity.resbean.ResDynamicBean;
import com.hongning.railway.entity.resbean.ResExamCompleteBean;
import com.hongning.railway.entity.resbean.ResExamItem;
import com.hongning.railway.entity.resbean.ResExperienceBean;
import com.hongning.railway.entity.resbean.ResKaoHeBean;
import com.hongning.railway.entity.resbean.ResKaoHeListBean;
import com.hongning.railway.entity.resbean.ResMemberInfo;
import com.hongning.railway.entity.resbean.ResNewsBean;
import com.hongning.railway.entity.resbean.ResNewsDetail;
import com.hongning.railway.entity.resbean.ResOptionBean;
import com.hongning.railway.entity.resbean.ResPhotoItem;
import com.hongning.railway.entity.resbean.ResScoreRankBean;
import com.hongning.railway.entity.resbean.ResScoreRankInfo;
import com.hongning.railway.entity.resbean.ResVideoBean;
import com.hongning.railway.entity.resbean.UpdateUserInfoBean;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import me.goldze.mvvmhabit.http.BaseResponse;

/**
 * Created by goldze on 2019/3/26.
 */
public class HttpDataSourceImpl implements HttpDataSource {
    private ApiService apiService;
    private volatile static HttpDataSourceImpl INSTANCE = null;

    public static HttpDataSourceImpl getInstance(ApiService apiService) {
        if (INSTANCE == null) {
            synchronized (HttpDataSourceImpl.class) {
                if (INSTANCE == null) {
                    INSTANCE = new HttpDataSourceImpl(apiService);
                }
            }
        }
        return INSTANCE;
    }

    public static void destroyInstance() {
        INSTANCE = null;
    }

    private HttpDataSourceImpl(ApiService apiService) {
        this.apiService = apiService;
    }

    @Override
    public Observable<BaseResponse<LoginEntity>> login(String username, String password) {
        return apiService.userLogin(username,password);
    }

    @Override
    public Observable<BaseResponse<List<NewsCategoryBean>>> getCategory(ReqCategory reqCategory) {
        return apiService.getCategorys(reqCategory.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<DataBeanX>> getNewsList(ReqNewsBean reqNewsBean) {
        return apiService.getNews(reqNewsBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<List<ResNewsBean>>> getTop5(ReqNewsBean reqNewsBean) {
        return apiService.getBannerData(reqNewsBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<ResDynamicBean>> getNewsDynamicList(ReqDynamicBean info) {
        return apiService.getNewsDynamicList(info.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<ResNewsDetail>> getNewsDetail(ReqNewDetail reqNewDetail) {
        return apiService.getNewsDetail(reqNewDetail.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<BaseRes<List<ResPhotoItem>>>> getDynamicPhotos(ReqDynamicBean reqDynamicBean) {
        return apiService.getDynamicPhotos(reqDynamicBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<BaseRes<List<ResVideoBean>>>> getVideoList(ReqVideoBean reqVideoBean) {
        return apiService.getVideoList(reqVideoBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse> logout() {
        return apiService.userLogOut();
    }

    @Override
    public Observable<BaseResponse<BaseResExam<ResExamItem>>> getExamList(ReqNewsBean reqNewsBean) {
        return apiService.getExamList(reqNewsBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<List<ResExamCompleteBean>>> getExamCompleteList(ReqNewsBean reqNewsBean) {
        return apiService.getExamCompleteList(reqNewsBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<BaseResExam<ResOptionBean>>> getquestionslist(ReqExam reqExam) {
        return apiService.getquestionslist(reqExam.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<ThreesessionSanDoneLessonBean>> selectmeet(MettingMessageBean mettingMessageBean) {
        return apiService.selectmeet(mettingMessageBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<ResAnswerSubmitBean>> answerSubmit(ReqAnswerSubmit reqAnswerSubmit) {
        return apiService.answerSubmit(reqAnswerSubmit.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<BaseResExam<ResAnswerCheck>>> answerCheck(ReqAnswerCheck reqAnswerCheck) {
        return apiService.answerCheck(reqAnswerCheck.toRequestBody());
    }

    @Override
    public Observable<BaseResponse> updatesign(UpdatesignBean updatesignBean) {
        return apiService.updatesign(updatesignBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<List<ThreesessionSanDoneLessonBean.DataBean>>> selectMessage(MettingMessageBean mettingMessageBean) {
        return apiService.selectMessage(mettingMessageBean.toRequestBody());
    }


    @Override
    public Observable<BaseResponse> addvieworPraise(ReqAddViewOrPraise reqAddViewOrPraise) {
        return apiService.addPageViewAndPraise(reqAddViewOrPraise.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<RosterMainBean>> selectCadreList(MettingMessageBean mettingMessageBean) {
        return apiService.selectCadreList(mettingMessageBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<BaseResCadreListBean<ResCadreBean>>> getCadreList(ReqCadreListBean reqCadreListBean) {
        return apiService.getCadreMemberList(reqCadreListBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<List<ResMemberInfo>>> getCadreMemberList(ReqMemberList reqCadreListBean) {
        return apiService.getCadreMemberStudentList(reqCadreListBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<String>> submitCadreMember(ReqMemberList reqCadreListBean) {
        return apiService.submitCadreMember(reqCadreListBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<String>> addScore(ReqAddScoreBean reqAddScoreBean) {
        return apiService.addScore(reqAddScoreBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<ResScoreRankInfo>> scoreRank(ReqScoreBean reqScoreBean) {
        return apiService.getScoreRankInfo(reqScoreBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<ResDetailScore>> ScoreDetail(ReqScoreBean reqScoreBean) {
        return apiService.getScoreDetail(reqScoreBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<Boolean>> addExperience(ReqAddExperience reqAddExperience) {
        return apiService.addExperience(reqAddExperience.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<ResExperienceBean>> getExperienceList(ReqExperienceList reqExperienceList) {
        return apiService.selectExperience(reqExperienceList.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<Boolean>> updateExperience(ReqUpdateExperience reqUpdateExperience) {
        return apiService.updateExperience(reqUpdateExperience.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<List<QuestionResultBean>>> selectAssessesIntegral(ReqAssessesIntegral reqAssessesIntegral) {
        return apiService.selectAssessesIntegral(reqAssessesIntegral.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<String>> addAssessesIntegral(ReqAssessesIntegralBean reqAssessesIntegral) {
        return apiService.addAssessesIntegral(reqAssessesIntegral.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<String>> saveAssessesIntegral(ReqAssessesIntegralBean reqAssessesIntegral) {
        return apiService.saveAssessesIntegral(reqAssessesIntegral.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<List<ResScoreRankBean>>> allrankScore(ReqScoreBean reqScoreBean) {
        return apiService.allrankScore(reqScoreBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<List<ResScoreRankBean>>> zhiburankScore(ReqScoreBean reqScoreBean) {
        return apiService.zhiburankScore(reqScoreBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<List<ResScoreRankBean>>> allHnrankScore(ReqScoreBean reqScoreBean) {
        return apiService.allHnrankScore(reqScoreBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<List<ResScoreRankBean>>> zhibuHnrankScore(ReqScoreBean reqScoreBean) {
        return apiService.zhibuhnrankScore(reqScoreBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<List<ResKaoHeBean>>> getPartyExamInfoListForApp(ReqKaoHeListBean reqAssessesIntegral) {
        return apiService.getPartyExamInfoListForApp(reqAssessesIntegral.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<List<ResKaoHeBean>>> getPartyExamInfoDetailsById(ReqKaoHeGroupBean reqAssessesIntegral) {
        return apiService.getPartyExamInfoDetailsById(reqAssessesIntegral.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<QuestionResultListBean>> selectStatisticsByPage(QuestionRequestListBean questionRequestListBean) {
        return apiService.selectStatisticsByPage(questionRequestListBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<String>> saveCadreMember(ReqMemberList reqCadreListBean) {
        return apiService.addSaveAssesses(reqCadreListBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<ResKaoHeListBean>> selectTestScoreAPP(ReqKaoHeBaseBean reqAssessesIntegral) {
        return apiService.selectTestScoreAPP(reqAssessesIntegral.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<ReqAssessesIntegralBean>> selectAssessesIntegralById(QueryCpInfoRequestBean queryCpInfoRequestBean) {
        return apiService.selectAssessesIntegralById(queryCpInfoRequestBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<LoginEntity>> updateStaffInfo(UpdateUserInfoBean updateUserInfoBean) {
        return apiService.updateStaffInfo(updateUserInfoBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<List<Fileterbean>>> getTypesForApp() {
        return apiService.getTypesForApp();
    }

    @Override
    public Observable<BaseResponse<ResScoreRankInfo>> getScoreRank(ReqScoreBean reqScoreBean) {
        return apiService.getScoreRank(reqScoreBean.toRequestBody());
    }

    @Override
    public Observable<BaseResponse<String>> addExamScore(ReqAddExamScore reqAddExamScore) {
        return apiService.addScoreForExam(reqAddExamScore.toRequestBody());
    }

    @Override
    public Observable<BaseResponse> addPageView(ReqAddPages reqAddPages) {
        return apiService.addPageView(reqAddPages.toRequestBody());
    }
}
